/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.wii.elpro.dao.hb;

import com.wii.elpro.dao.CabangDAOInterface;
import com.wii.elpro.dao.HibernateUtil;
import com.wii.elpro.entity.Cabang;
import java.util.List;
import org.hibernate.Session;

/**
 *
 * @author hendro
 */
public class CabangDAOImpl extends DAOGenericImpl implements CabangDAOInterface{

    public Cabang getCabang(long id) throws Exception {
        HibernateUtil.beginTransaction();
        Session em = HibernateUtil.getSession();
        try{
            return (Cabang)em.load(Cabang.class, id);          
        }catch(Exception ex){
            throw ex;
        }
    }

    public List<Cabang> getCabangs() throws Exception {
        HibernateUtil.beginTransaction();
        Session em = HibernateUtil.getSession();
        try{
            return em.createQuery("SELECT c FROM Cabang c").list();
        }catch(Exception ex){
            throw ex;
        }
    }
}
